package com.crowbar.map.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.crowbar.map.common.R;
import com.crowbar.map.entity.*;
import com.crowbar.map.service.MapInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * (MapInfo)表控制层
 *
 * @author makejava
 * @since 2025-01-03 16:31:18
 */
@RestController
@RequestMapping()
public class MapInfoController{
    /**
     * 服务对象
     */
    @Resource
    private MapInfoService mapInfoService;


    @PostMapping("/citys")
    public R getCitys(@RequestBody EventsInfoReq eventsInfoReq) {
        List<LocationInfo> result = mapInfoService.getCitys(eventsInfoReq);
        return R.ok().message("查询成功").code(200).data("data",result);
    }

    @PostMapping("/items/query")
    public R getMapInfo(@RequestBody MapInfoReq mapInfoReq){
        Map<String, List<MapInfo>> result = mapInfoService.getMapInfo(mapInfoReq);
        return R.ok().message("查询成功").code(200).data("data",result);
    }

    @PostMapping("/event/add")
    public R addEvent(@RequestBody EventsInfoReq eventsInfoReq){
        Boolean result = mapInfoService.addEvent(eventsInfoReq);
        if(result){
            return R.ok().message("新建成功").code(200).data("data","");
        }
        else {
            return R.error();
        }

    }

    @PostMapping("/event/datetool")
    public R getEventByName(@RequestBody EventsInfoReq eventsInfoReq) throws ParseException {
        List<EventsInfo> result = mapInfoService.getEventByName(eventsInfoReq);
        return R.ok().message("查询成功").code(200).data("data",result);

    }


    @GetMapping("/event/query")
    public R getAllEvents(){
        List<EventsInfo> result = mapInfoService.getAllEvents();
        return R.ok().message("查询成功").code(200).data("data",result);

    }

//    @PostMapping("/city/updateLocation")
//    public R cityUpdateLocation(@RequestParam String city){
//        Boolean result = mapInfoService.cityUpdateLocation(city);
//        if(result){
//            return R.ok().message("修改成功").code(200).data("data","");
//        }
//        else {
//            return R.error();
//        }
//
//    }


}

